<?php
session_start();
require_once('../include/connect.inc.php');
if($_SESSION['sess_id'] <> session_id()){
?>
 <SCRIPT LANGUAGE="JavaScript">
			alert("กรุณาเข้าสู่ระบบให้ถูกต้องตามขั้นตอน...!");
			location="login.php";
</script>
<?php }?>
<?php
if($_REQUEST['subject_id'] != "") //if admin has data
{
	$del_id   = (int)$_REQUEST['subject_id'];
	$sql_del  = "delete from tb_subject where subject_id = '$subject_id';";
	mysql_query($sql_del) or die(mysql_error());
	$admin_id = $rs['subject_id'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Model Test Program</title>
<link rel="stylesheet" type="text/css" href="../template/template_style_wood.css">
</head>

<body>
<div id="menu"><div><img src="../images/icon-m.png" /></div>
<div id="menulinks">
		<a  href="../person_tea.php">ข้อมูลส่วนตัว</a>
		<a href="../tea_edit.php">เปลี่ยนรหัสผ่านใหม่</a>
        
        <a class="active"   href="show_subject.php">จัดการรายวิชา</a>
		<a href="../teacher_test.php">จัดการข้อสอบ</a>
        <a href="../teacher_tests.php">จัดการชุดข้อสอบ</a>
        <a  href="../agree_set.php">กำหนดสิทธิ์</a>
		<a href="../exam/tea_chack.php">ตรวจสอบคะแนน</a>
        <a href="../news/manage_news.php">ประกาศข่าวสาร</a>
        <a href="../problem/send_problem.php">แสดงความคิดเห็น</a>
         <a  href="../problem/teacher_message.php">กล่องข้อความ</a>
        <a href="../logout.php">ออกจากระบบ</a>
		</div></div>           
 <div id="p3">    
<div id="header"></div>
   <div id="page"><div id="p1">คุณ<?php echo $_SESSION['teacher_name'];?><hr/>
				<form name="form1" id="form1" method="post" action="show_subject.php">
					<table  border="0" cellspacing="0" cellpadding="0">
      					<tr>
        					<th align="left">จัดการรายวิชา</th>
        					<th align="right"><a href="insert_subject.php"> <img src="../images/add.png" border="0" /> </a> </th>
      					</tr>
    				</table>
					<table id="table" width="396" border="0" cellspacing="0" cellpadding="0">
  						<tr>
    						<th width="100" align="center">ลำดับที่</th>
    						<th width="115" align="center">วิชา</th>
    						<th width="65" align="center">ลบ</th>
    						<th width="58" align="center">แก้ไข</th>
    						<th width="58" align="center">ให้สิทธิ์อาจารย์</th>
  						</tr>
   						<?php
							$query  = query("SELECT * FROM tb_subject where r_teacher_id='".$_SESSION[id]."' ORDER BY subject_id asc");
							$count	= 1;
							while ($rs = fetch_array($query)) {
							$subject_id	  = $rs['subject_id'];
		    				$subject_name = $rs['subject_name'];
						?>
  						<tr>
    						<td align="center"><?php echo $count;echo ".";?></td>
    						<td> <a href="show_topic.php?subject_id=<? echo "$subject_id";?>"> <?php echo $subject_name;?> </a> </td>
    						<td align="center">
      							<script language="JavaScript">
									function Conf<?=$rs["subject_id"]; ?>(object) {
										if (confirm("ยืนยันการลบรายวิชา") ==true) {
											return true;
										}
											return false;
									}
          						</script>
							<a href="show_subject.php?subject_id=<?=$rs["subject_id"];?>" onClick="return Conf<?=$rs["subject_id"]; ?>(this)"> <img src="../images/delete1.png" border="0" /></a></td>
    						<td align="center"><a href="edit_subject.php?subject_id=<?=$subject_id;?>"><img src="../images/edit.png" border="0" /></a></td>
    						<td align="center"><a href="agree_teacher.php?subject_id=<?=$subject_id;?>&subject_name=<?php echo $rs['subject_name'];?>"><img src="../images/true.jpg" border="0" height="20" width="20" /></a></td>
  						</tr>
						<?php 
  							$count++; 
							} 
						?>
					</table>
	  </form>
    </div>
    </div>
<div id="footer"></div>
</div>
</body>
</html>
